package com.jbit.controller;

import com.jbit.dto.DmItemFloor;
import com.jbit.service.DmItemFloorService;
import com.jbit.service.DmItemService;
import com.jbit.service.DmItemTypeService;
import com.jbit.utils.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/item/api/p/index")
public class IndexController {
    @Autowired
    private DmItemTypeService dmItemTypeService;
    @Autowired
    private DmItemService dmItemService;
    @Resource
    private DmItemFloorService dmItemFloorService;

    @PostMapping("/queryAllType")
    public ResponseEntity queryAllType() {
        return ResponseEntity.sendSuccess(dmItemTypeService.queryAllType());
    }

    @PostMapping("/queryTransverse")
    public ResponseEntity queryTransverse() {
        return ResponseEntity.sendSuccess(dmItemTypeService.queryHeaderType());
    }

    @PostMapping("/queryBanner")
    public ResponseEntity queryBanner() {
        return ResponseEntity.sendSuccess(dmItemService.queryBanner());
    }

    @PostMapping("/queryTodayRecommend")
    public ResponseEntity queryTodayRecommend() {
        return ResponseEntity.sendSuccess(dmItemService.queryBanner());
    }

    @PostMapping("/queryToSaleItem")
    public ResponseEntity queryToSaleItem() {
        return ResponseEntity.sendSuccess(dmItemService.queryToSaleItem());
    }

    @PostMapping("/queryFloorItems")
    public ResponseEntity queryFloorItems() {
        return ResponseEntity.sendSuccess(dmItemFloorService.queryAllFloor());
    }

    @PostMapping("/queryHotItems")
    public ResponseEntity queryHotItems(@RequestBody DmItemFloor floor) {

//        return ResponseEntity.sendSuccess();
        return ResponseEntity.sendSuccess(dmItemService.queryFloorItemByTypeId(floor.getItemTypeId()));
    }


}
